package l1j.server.server.command.executor;
import java.util.Iterator;

import l1j.opqlo.Server.L1World.L1World;
import l1j.server.Config;
import l1j.server.server.model.L1Teleport;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.serverpackets.S_SystemMessage;

public class L1Activity implements L1CommandExecutor {
	public static L1CommandExecutor getInstance() {
		return new L1Activity();
	}
	private L1Activity() {
	}
	// @Override
	@Override
	public void execute(L1PcInstance pc, String cmdName, String arg) {
		if (arg.equalsIgnoreCase("開始")) {
			final int[]loc = {pc.getX() , pc.getY() , pc.getMapId() };
			Config.活動座標 =loc;
			L1World.getInstance().broadcastPacketToAll(new S_SystemMessage("\\aG特殊活動已開啟。"));
			L1World.getInstance().broadcastPacketToAll(new S_SystemMessage("\\aJ輸入指令【 .參加活動】進入活動地圖。"));
		}else if(arg.equalsIgnoreCase("結束")){
			L1World.getInstance().broadcastPacketToAll(new S_SystemMessage("\\aG特殊活動已關閉，謝謝各位參加。"));
			final Iterator<L1PcInstance> ite =L1World.getInstance().getAllPlayers().iterator();
			while(ite.hasNext()){
				final L1PcInstance tpc = ite.next();
				if(tpc.getMapId() == Config.活動座標[2]){
					L1Teleport.teleport(tpc, 32810 ,  32833 , (short)1784 , 0 ,false);	
				}
			}
			final int[]loc = {0 , 0 ,0 };
			Config.活動座標 =loc;
		} else {
			pc.sendPackets(new S_SystemMessage("請輸入: ."+cmdName + " 開始、結束 。"));
		}
	}
}
